﻿#if TASKSUPPORT
using System.Threading.Tasks;
#endif
using System.Windows.Input;
using JetBrains.Annotations;
using MugenMvvmToolkit.Models;

namespace MugenMvvmToolkit.Interfaces.ViewModels
{
    /// <summary>
    ///     Represents the base interface for all view models which can be closed.
    /// </summary>
    public interface ICloseableViewModel : IViewModel
    {
        /// <summary>
        ///     Gets or sets a command that attempts to remove this workspace from the user interface.
        /// </summary>
        ICommand CloseCommand { get; set; }

#if TASKSUPPORT
        /// <summary>
        ///     Tries to close view-model.
        /// </summary>
        /// <param name="parameter">The specified parameter, if any.</param>
        /// <returns>An instance of task with result.</returns>        
        Task<bool> Close([CanBeNull]object parameter);
#else
        /// <summary>
        ///     Tries to close view-model.
        /// </summary>
        /// <param name="parameter">The specified parameter, if any.</param>
        /// <returns>An instance of operation with result.</returns>        
        IOperationResult<bool> Close([CanBeNull]object parameter);
#endif

        /// <summary>
        ///     Called when <see cref="ICloseableViewModel" /> removed from the workspace.
        /// </summary>
        event ViewModelClosedDelegate Closed;
    }

    /// <summary>
    ///     Notifies clients that a model closing.
    /// </summary>
    public interface INotifyViewModelClosing : ICloseableViewModel
    {
        /// <summary>
        ///     Called when <see cref="ICloseableViewModel" /> removing from the workspace.
        /// </summary>
        event ViewModelClosingDelegate Closing;
    }
}